package com.demo.test.prototype;

import com.demo.test.prototype.iml.Prototype;

import java.io.IOException;
import java.util.Date;

public class Client {

    public static void main(){
        Person person = new Person();
        WorkLog workLog = new WorkLog();

        workLog.setCompany("yd");
        workLog.setTime(new Date().toString());

        person.setName("sun");
        person.setAge("29");
        person.setWorkLog(workLog);

        try{

            //浅克隆
            Person wPerson = (Person)person.getShallowClone();
            wPerson.setName("wang");
            wPerson.setAge("26");
            //深克隆
            Person zPerson = (Person)person.getDeepClone();
            zPerson.setName("zheng");

            //修改person工作
            person.getWorkLog().setCompany("ali");

            System.out.println("person.name:"+person.getName()+",--person.age:"+person.getAge()+",--person.work.company:"+person.getWorkLog().getCompany()+",--person.work.date:"+person.getWorkLog().getTime());
            System.out.println("wPerson.name:"+wPerson.getName()+",--wPerson.age:"+wPerson.getAge()+",--wPerson.work.company:"+wPerson.getWorkLog().getCompany()+",--wPerson.work.date:"+wPerson.getWorkLog().getTime());
            System.out.println("zPerson.name:"+zPerson.getName()+",--zPerson.age:"+zPerson.getAge()+",--zPerson.work.company:"+zPerson.getWorkLog().getCompany()+",--zPerson.work.date:"+zPerson.getWorkLog().getTime());

       }catch (Exception e){
            e.printStackTrace();

        }





    }
}
